package com.jckj.core.util;

import com.jckj.core.entity.SysUser;
import com.jckj.core.vos.LoginUserVo;

/**
 * <p>
 *     用户工具辅助类
 * </p>
 * @author liuzhiyuan
 * @date 2018-01-08
 */
public class UserUtils {

    /**
     * 查询当头登录用户
     * @return
     */
    public static LoginUserVo getLoginUser(){
        return SpringContextHolder.getBean(LoginUserVo.class);
    }

    /**
     * 设置当前登录用户
     * @param sysUser
     */
    public static void setLoginUser(SysUser sysUser){
        LoginUserVo loginUserVo = SpringContextHolder.getBean(LoginUserVo.class);
        loginUserVo.setId(sysUser.getId());
        loginUserVo.setLoginName(sysUser.getLoginName());
        loginUserVo.setName(sysUser.getLoginName());
    }

    /**
     * 登出
     */
    public static void logout(){
        LoginUserVo loginUserVo = SpringContextHolder.getBean(LoginUserVo.class);
        loginUserVo.clear();
    }


}
